package com.cetccst.securitysuite.fragments;

import androidx.fragment.app.Fragment;

import com.cetccst.securitysuite.BR;
import com.cetccst.securitysuite.R;
import com.cetccst.securitysuite.databinding.FragmentMqttBinding;
import com.cetccst.securitysuite.fragments.viewmodel.MqttViewModel;
import com.cetccst.securitysuite.mqtt.SSMqtt;
import cn.com.cetccst.uicomponents.binding.app.DataBindingConfig;

public class MqttFragment extends BaseFragment<FragmentMqttBinding> {

    private MqttViewModel mqttViewModel;

    public MqttFragment() {
        // Required empty public constructor
    }

    @Override
    protected void initViewModel() {
        mqttViewModel =getFragmentScopeViewModel(MqttViewModel.class);
        mqttViewModel.registerMqtt();
    }

    @Override
    protected DataBindingConfig getDataBindingConfig() {
        return new DataBindingConfig(R.layout.fragment_mqtt, BR.viewModel, mqttViewModel)
                .addBindingParam(BR.click, new Click());
    }

    public class Click {

        public void connect() {
            SSMqtt.getInstance().connect();
        }

        public void clear() {
            mqttViewModel.content.setValue("");
        }
    }
}